// ignore_for_file: non_constant_identifier_names

import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

class ChartPage extends StatefulWidget {
  void Function(int freq, double gain, int index, bool isMove)? onMove;
  ChartPage({super.key, required this.onMove});
  @override
  State<ChartPage> createState() => _ChartPageState();
}

class _ChartPageState extends State<ChartPage> {
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constrains) {
        ///计算绘图的真实宽度，高度
        var size = Size(constrains.maxWidth, constrains.maxHeight);
        var padding = const EdgeInsets.only(left: 28, right: 10, top: 5, bottom: 20);
        return Container(
          // decoration: boxDecoration(5),
          padding: EdgeInsets.all(10),
          child: Obx(() {
            var global = globalController.rxModel.value;
            var ch = global.ch_list[0];
            var sign = ch.sign_list[0];
            return ChartView(
              ch: ch,
              size: size,
              padding: padding,
              minY: sign.min_gain,
              maxY: sign.max_gain,
              showPoints: true,
              onMove: widget.onMove,
            );
          }),
        );
      },
    );
  }
}
